import React from 'react';
import { Route } from 'react-router';
import _ from 'lodash';
import App from './app';

const defaultReplace = (replace, url)=>{
  const asgardTree = window.__INIT_STATE__.asgardTree[0].resourceBos[0].resourceBos;
  const find = _.findIndex(asgardTree, (tree)=>{
    return tree.url&&_.endsWith(tree.url, url)
  })
  if(find < 0){
    replace(asgardTree[0].url.split('#')[1])
  }
}

const routes = [{
		path: '/',
    component: App,
    indexRoute: {
      onEnter: (nextState, replace)=>{ replace('/user') }
    },
    childRoutes: [
      {
        path: 'demo',
        component: require('page/demo')
      },
      {
        path: 'login',
        component: require('page/login')
      },
      {
        path: 'register',
        component: require('page/register')
      },
      {
        path: 'activity',
        component: require('page/activity/index')
      },
      {
        path: 'experience',
        component: require('page/experience/index')
      },
      {
        path: 'user',
        component: require('page/user/index')
      },
      {
        path: 'interview',
        component: require('page/interview/index')
      },
      {
        path: 'school',
        component: require('page/school/index')
      },
      {
        path: 'teacher',
        component: require('page/teacher/index')
      },
      {
        path: 'plan',
        component: require('page/plan/index')
      },
      {
        path: 'course',
        component: require('page/course/index')
      },
      {
        path: 'testing',
        component: require('page/testing/index')
      },
      {
        path: 'bannerimg',
        component: require('page/bannerimg/index')
      },
      {
        path: 'dictionary',
        component: require('page/dictionary/index')
      }
    ]
	},
	{
		path: '*',
		component: require('page/NoMatch')
	}
]
export default routes;
